package ru.msu.cmc.sp.oberon2;

public class ArrayType extends Symbol implements Type {
	Type elementType;
	int length;
    public ArrayType(Type elementType, int length) {
        super(elementType+"[]");
        this.elementType = elementType;
        this.length = length; //length == -1 => open array
    }
    public boolean equals(Object obj) {

    	if (obj instanceof ArrayType) {
    		if (((ArrayType)obj).elementType == this.elementType && ((ArrayType)obj).length == this.length &&
    				this.length > 0) 
    			return true;
    	}
    	return false;
    }
    public int getTypeIndex() { return 0; }
    public boolean isNumber() {return false;}
    public boolean isInt() {return false;}
    public boolean isReal() {return false;}
    public boolean isString() {
    	return elementType.equals(SymbolTable._char);
    }
}
